package com.example.ivideo_2211a.adapter

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.example.ivideo_2211a.R

class GuideAdapter(
    private val images: List<Int>,
    private val titles: List<String>,
    private val descriptions: List<String>
) : RecyclerView.Adapter<GuideAdapter.GuideViewHolder>() {
    
    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): GuideViewHolder {
        val view = LayoutInflater.from(parent.context)
            .inflate(R.layout.item_guide_page, parent, false)
        return GuideViewHolder(view)
    }
    
    override fun onBindViewHolder(holder: GuideViewHolder, position: Int) {
        holder.bind(images[position], titles[position], descriptions[position])
    }
    
    override fun getItemCount(): Int = images.size
    
    class GuideViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
        private val ivRobot: ImageView = itemView.findViewById(R.id.ivRobot)
        private val tvTitle: TextView = itemView.findViewById(R.id.tvTitle)
        private val tvDescription: TextView = itemView.findViewById(R.id.tvDescription)
        
        fun bind(imageRes: Int, title: String, description: String) {
            ivRobot.setImageResource(imageRes)
            tvTitle.text = title
            tvDescription.text = description
            
            // 添加进入动画
//            ivRobot.alpha = 0f
//            tvTitle.alpha = 0f
//            tvDescription.alpha = 0f
//
//            ivRobot.animate()
//                .alpha(1f)
//                .scaleX(1f)
//                .scaleY(1f)
//                .setDuration(600)
//                .setStartDelay(100)
//                .start()
//
//            tvTitle.animate()
//                .alpha(1f)
//                .translationY(0f)
//                .setDuration(500)
//                .setStartDelay(300)
//                .start()
//
//            tvDescription.animate()
//                .alpha(1f)
//                .translationY(0f)
//                .setDuration(500)
//                .setStartDelay(400)
//                .start()
        }
    }
}